home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
2336A.ZIP
/
SCRDISK2.EXE
/
arc
/
TUTORPT2.DOC
< prev
Wrap
Text File
|
1990-04-29
|
41KB
|
1,117 lines
Page T-2.1
TURBO SCREDIT TUTOR PART II.(Field Processing stmts).(Section T-2)
Introduction to Turbo ScrEdit Tutor Part II.....T-2.1
Using the processing specifications editor......T-2.2
SET.............................................T-2.5
REQUIRED........................................T-2.5,6,11,14
HELP............................................T-2.6
REM.............................................T-2.7
IN..............................................T-2.7,8,11,12,14
UP SHIFT ON/OFF.................................T-2.7,9,11
IF [AND,OR] THEN/ENDIF..........................T-2.8,9,10,11,12,
13,
ERROR...........................................T-2.10
SKIP............................................T-2.8
SKIP IF BLANK...................................T-2.10
EDIT............................................T-2.14
Page T-2.1
Introduction to Turbo ScrEdit Tutor Part II
-----------------------------------------------------------------
In PART ONE you learned how to create a screen file, create and
edit screens inside the screen file. You also learned how to
compile a screen and set the screen field type, change the
order that the screens fields are processed in, change the
field display and prompt color assignments, test a screen, and
finally, how to generate source code for processing the screens.
In PART TWO we are going to take a look at using the field
processing language that is built into Turbo ScrEdit. Using the
field processing language you can edit data entered into fields
by specifying a range of values or a predetermined list of
specific values, or any mixture of both. Turbo ScrEdit also
allows you to establish more than one set of validation
specification to be used to validate the contents of a field
differently depending on the values of one or more other fields
on the screen.
We will also discuss using field processing statements for
assigning field help messages, setting initial field values, and
specifying field edit masks.
Before we get started you will want to make sure that you have
copied the file "ScrDemo.Scr" into your current work area or
disk, and that you have the necessary files available so you can
run Turbo ScrEdit.
Okay, we are ready to begin.
LOAD AND RUN TURBO SCREDIT.
PRESS THE "Y" KEY TO ACCESS THE MAIN MENU
PRESS F1
TYPE SCRDEMO
PRESS HOME
The screen name "Demo_Screen" should now be in the highlighted
line of the screen name section of the "Work Screen" window.
Before we precede lets get a printed listing of this screen that
we can refer to during the discussion that follows.
PRESS F5
Turbo ScrEdit responds with "Ready Printer...<ESC> to Abort". If
you do not have a printer just press ESC otherwise press any
other key to start printing the screen listing.
PRESS PGUP to advance the report out of your printer.
Page T-2.2
PRESS F4 the compile screen option.
PRESS Y to accept the current settings.
Using the processing specifications editor.
-----------------------------------------------------------------
Before we begin to explore field processing statements lets take
a look at the editing facilities for adding, changing, and
deleting processing specification lines.
At this point you will be looking at the first field on the
screen "SetDemo1". There are two things I want you to notice
here. First, notice the function key label for F2 that reads
"Edit Process". Second, notice in the lower portion of the screen
there is a line that starts with the word SET.
PRESS F2
The line in the bottom portion of the screen has become
highlighted and the function key labels have changed. This
highlighted line is the "Edit Line", and has all the editing
features of any field on a Turbo ScrEdit screen. That is the left
and right arrows move the cursor, the INSERT key toggles insert
mode on and off, the DELete key deletes the character at the
cursor, and the BACKSPACE key deletes the character to the left
of the cursor and drags the remainder of the line to the left one
character.
Each field on the screen can have up to 50 lines of Processing
statements assigned to it. First lets discuss adding new lines
of processing statements.
PRESS F3
The F3 key is used to insert a line into the text at the current
line. The line with the SET statement just moved down one line
and a new blank line was added above it.
Type: REM THIS IS MY FIRST LINE and PRESS ENTER
When the ENTER key was pressed the lines scrolled up in the
editor window so the cursor is now positioned on the original
line with the SET statement.
PRESS ENTER again
Pressing the ENTER key will always cause the screen to scroll one
line. Notice that when ENTER was pressed on the last line of
text, a new blank line is been added to the screen.
Type: REM THIS IS MY SECOND LINE and PRESS ENTER
Type: REM and PRESS ENTER
Type: REM again and PRESS ENTER.
Page T-2.3
Now that you have seen how lines are added, lets look at how to
scroll through lines of text. The most basic method is pressing
the ENTER key to cause the screen to scroll up one line. The F5,
F6, F7, and F8 keys can also be used for scrolling text.
PRESS F5
The cursor is placed on the first line of processing statements.
PRESS F6
The cursor is placed on the last line of processing statements.
PRESS F7 - 4 times
Each time you press F7 the screen scrolls down one line until you
reach the first line of text.
PRESS F8 - 4 times.
Each time you press F8 the screen scroll up one line just as
when the ENTER key pressed. The only real difference between
using the F8 key and the ENTER key is that only the ENTER key
will append a new line for text.
Next we will look at deleting lines of text.
PRESS F7 to scroll up one line of text.
PRESS F2 to delete the current line.
The line is deleted and the last line moves up.
PRESS F2 again.
Be careful at this point not to delete the original line with the
SET statement. If you do delete it by accident just re-key it
using the example on the printed screen listing.
PRESS F7
PRESS F2
We are now back to having only the original SET statement left on
this field.
Next we will review the help facility.
PRESS F1
The help screen menu has filled the screen. Notice that the
first three topics listed on the screen apply to defining fields
Page T-2.4
and using the compile screen. All remaining topics describe the
field processing statements that are recognized by Turbo ScrEdit.
PRESS ESC to exit the help screen.
PRESS ESC to exit the field processing editor.
Now that you understand how to access the field processing
editor, and how to use it, we are going to return to the main
menu and see how the field processing statements work. Before we
leave you may wish to browse through the screen fields and look
at the other field processing statements.
When you are ready..
PRESS ESC to return to the main menu.
PRESS F10
We have just entered Turbo ScrEdit's screen test facility.
Before we begin you will need the printed listing of the screen
and it's fields. We will be discussing the field processing
statements for each field as they are listed on the listing. I
will not attempt to give a detailed description of the format of
the processing statements, rather, we will look at the results
as Turbo ScrEdit analyzes them. For the details on how each
statement is formatted I will ask you to look up each statement
as it is discussed in the on-line help system.
For practice lets look up the SET statement in the on-line help
system. The SET statement will be the first field processing
statement that we will be discussing.
PRESS ESC
PRESS F7
Next, lets locate the SET statement in the index.
PRESS PGDN 3 times
You should now see a list of topics for field processing
statements listed under the topic "Using field processing
specifications." Find the SET statement in the list and:
PRESS G
Type:20 (or the line number next to the SET index line)
Read the help text describing the SET statement.
Page T-2.5
PRESS ESC when you are finished with the help screen.
PRESS F10 to resume testing our screen.
Turn to page 1 of the screen listing. At the top of the page you
see information about the screen: the screen name, the screen
file name, and the name of the screen buffer that you will
include in your programs. Next on the page we see the screen text
and fields are printed.
Next we see the "SCREEN FIELD DEFINITIONS" section of the
report. Information about each field on the screen is listed
here. Lines of dashes separate each of the field descriptions,
and lines of dots mark where that fields field processing
statements begin.
Lets begin by looking the first three screen fields up in the
screen listing. We see that these are display only fields, and
that they are now displaying the initial values assigned to them
by SET statements.
The SET statement:
-------------------------------------------------------------
You will recall from reading the help text on SET statements
that the SET statement is used to assign fields initial
values. The first two fields on the screen are displaying the
text as it has be type in the message portion of the SET
statements.
Next notice the field named SetDemo3, and the special format
of it's SET statement: SET 'SYSDATE'
As described in the on-line help text, when Turbo ScrEdit
encounters this set statement it will read the current date
set in DOS and assign it to the field in MM/DD/YYYY format.
See the description of S_CLEARSCREEN in the Turbo ScrEdit
Programmers Reference manual for information on how to use
SET statements in your programs.
** PLEASE NOTE **
The set statement must be keyed in one of the fields first
three lines of processing statements. If it is keyed in the
fourth or greater line, it will be ignored by Turbo ScrEdit.
Next locate the "OP" field on the screen listing and lets look at
the processing statements assigned to it.
The REQUIRED statement:
-------------------------------------------------------------
By looking at the screen that is displayed, we see that there
are 5 possible options. Because option is a key field on the
screen I have made it a REQUIRED field.
Take a moment and look up REQUIRED in the help system.
Page T-2.6
PRESS ENTER
A message has appeared instructing you that this field is
required. Notice in the printed listing for this field that
the message now displayed on the bottom line of the screen
has been coded as part of the REQUIRED statement. This
message is optional. Had I coded only the REQUIRED statement
with no message, the default message described in the help
text would have been displayed.
The HELP statement
-------------------------------------------------------------
Next we see a HELP statement and a Help Message.
Take a moment and look up HELP in the on-line help system.
Type: ?
The help message for this field has been displayed on the
bottom line of the screen.
Help statements can be assigned to any field, and can be
accessed two ways.
1st - Typing a ? mark as the first character of a field will
cause the help message to be displayed.
2nd - Setting the S_AutoHelp switch to TRUE in your program
will cause help messages to be displayed automatically
as the cursor moves from field to field.
You can test this option now by pressing F1 to toggle
auto help mode ON. Then use the TAB key to move the
cursor from field to field. Pressing the F1 key again
will toggle auto help mode OFF.
Go ahead and try it..
PRESS F1
PRESS TAB 3 times and notice the help messages as they
are displayed.
PRESS F1
PRESS SHIFT and TAB 3 times notice that no help
messages are displayed as the cursor moves back to the
option field.
Page T-2.7
The REM statement
-------------------------------------------------------------
Next we see comments embedded in the field processing specs.
As you would expect, comments are ignored by Turbo ScrEdit.
If you would like to, look up REM in the on-line help system.
The IN statement
-------------------------------------------------------------
Be sure you take a moment here and look up the IN statement
in the on-line help. As you can see, using the IN statement
can be very simple to very complex depending on your need.
The IN statement is used to test the value of the field that
it is assigned to. This is a simple example that will test
the value keyed into OP to assure that it falls in the range
of 1 through 5.
Type 9 and PRESS ENTER
We see that the error message associated to the IN statement
has been displayed on the screen. We will not be able to
continue until a value of 1 to 5 has been entered in this
field.
Now lets move on and examine option 1 of this screen.
Type: 1 and press enter
A new message has been displayed on the message line and the
cursor has move to the first field in the option 1 section of the
screen. This section is designed to demonstrate using the IN
statement to edit data entered into a field for a valid value.
Lets look at the field processing statements for the screen fields
in the option 1 section of the screen.
The UP SHIFT ON/OFF statement
-------------------------------------------------------------
Look up UP SHIFT in the on-line help system.
UP SHIFT ON instructs Turbo ScrEdit to make all alphabetical
character comparisons with no regard to character case.
UP SHIFT OFF returns Turbo ScrEdit back to it's default mode
of character comparison where character case is significant.
The scope of the UP SHIFT ON statement is limited to the
field that it is coded for. When Turbo ScrEdit advances to
the next field on the screen it will return to the default
mode for character comparison where different character cases
compare differently.
Page T-2.8
The IF statement
-------------------------------------------------------------
Be sure to look this statement up in the on-line help system.
You will see that each of the fields in the option 1 section
of the screen have the same IF statements coded. Unless the
user has selected option 1 by keying a 1 in the option field,
Turbo ScrEdit will act on the SKIP statement and will skip
over these fields and will not analyze their processing
statements.
When the value of OP IS EQUAL to 1 then IN statement that
follows the IF statement is analyzed.
The SKIP statement
-------------------------------------------------------------
If you look up the SKIP statement you will see that it is
only used INSIDE the action part of an IF statement.
SKIP means that Turbo ScrEdit is to skip all other processing
statement for this field and accept whatever value has been
key in the field.
Lets take a look a how this statement works.
PRESS SHIFT TAB
Type: 2 and PRESS ENTER
Since we selected option 2, the IF statements on the three
fields that we are looking at instructed Turbo ScrEdit to
SKIP the processing statements for these fields. So the
cursor has advance to the first field in the option 2 section
of the screen.
PRESS F9 to re-init the screen.
Type: 1 and PRESS ENTER
The cursor has now returned to the first field in the option
1 section of the screen.
The IN statement
-------------------------------------------------------------
Each of the three fields have a IN statement to verify that
the values that they receive are in the specified ranges.
Notice that the first field's IN statement is composed of a
list of values. The list of values begins and ends with a
single quote, and each value in the list is separated by a
single quote. Notice also that only the first field uses the
UP SHIFT ON statement because it is making alphabetical
comparisons. The other fields will be making numeric
comparisons so character case will not matter.
Page T-2.9
Notice in the other three field's IN statement that they are
using the a range test. That is a minimum and maximum
acceptable value enclosed in single quotes and separated by a
caret (^).
Take a moment and try entering different kinds of values into
each of these fields.
When you are finished PRESS F9 to re-init the screen.
Type: 2 and PRESS ENTER
Locate OPTION 2's fields in the screen listing and lets examine
how they are set up before we try to use them.
OPTION 2 is designed to demonstrate the use of the IF statement.
The IF statement allows you to test the current field for a value
that is valid depending on the status of other fields on the
screen.
In this section we see four fields, "A", "B", "C", and a field
called the "Combined Field". Basically the processing specs are
going assure the following conditions:
1 - The value in the first field must be a "A"
The value in the second field must be a "B"
The value in the third field must be a "C"
2 - One of the three fields must be left blank.
3 - Two of the three fields must have a value.
4 - The value keyed into the combined field must match the
pattern of the top three fields.
With that in mind lets take a look at the processing specs to
accomplish this. First lets look at field A.
The IF statement 1
-------------------------------------------------------------
This IF statement is very similar to the IF statements we
looked at for OPTION 1's fields. If OP is not 2 then all the
remaining field processing statements are SKIPped.
The UP SHIFT ON
-------------------------------------------------------------
All comparisons are not case sensitive.
The IF statement 2
-------------------------------------------------------------
In this statement we introduce the AND logical operator. This
IF statement will test for condition #2 listed above; that at
least one of the three fields is left blank.
If all the fields are NOT blank then all three fields have
been assigned a value and the ERROR message is displayed.
Page T-2.10
The ERROR statement
-------------------------------------------------------------
The ERROR statement is used only in the action part of the IF
statement and forces the current field to return an ERROR
condition regardless of the value that has been keyed into it.
The message coded with the ERROR statement is displayed as a
result of the ERROR condition.
PRESS X 3 time and PRESS ENTER
The ERROR message is displayed.
The IF statement 2
-------------------------------------------------------------
This IF statement introduces the use of the OR statement. The
purpose of this IF statement is to finish testing for
condition #2 and test for condition #3 by making sure that
ONLY ONE of the fields are left blank and that at least two
of the fields have non blank values.
The IF statement 3
-------------------------------------------------------------
If the value being tested makes it to this IF statement we
know that two of the three fields in section 2 have values
keyed into them. So this if statement test to see if it is
one of the other fields that is blank.
IF one of the other fields are blank then the IN statement in
the action part of this IF statement test to make sure that
the A field has a value of 'A'.
If fields B or C were not blank then this if statement would
have assumed that this field was blank and would have skipped
to the next field B.
Now lets look at fields B and C.
Accept for the value tested for in the IN statements both of
these fields have the same processing specifications.
The SKIP IF BLANK statement
-------------------------------------------------------------
If Turbo ScrEdit makes it this far with out detecting an
error when it processed field A then it knows that if the
second field is blank the third field will have a value.
This statement does just what it implies. If the field has
been left blank with no value keyed into it Turbo ScrEdit
skip all the remaining field processing statements for the
field.
Page T-2.11
The IF statement
-------------------------------------------------------------
Again the field processing statements for these fields are
only to be processed if the user has selected option 2.
The IN statement
-------------------------------------------------------------
In these examples the upper and lower cases characters are
required because no UP SHIFT ON statement has been coded.
The next field "ABCD" uses IF statements to determine which of
the IN statements are to be used to test the value of the field.
If field A is blank then ABCD must have a value of " BC".
If field B is blank then ABCD must have a value of "A C".
If field C is blank then ABCD must have a value of "AB".
Go ahead and try keying values in these four fields and observe
the results.
When you are finished PRESS F9 to re-init the screen.
Type: 3 press ENTER
Now locate option 3's fields in the screen listing.
This option is to demonstrate the UP SHIFT statement.
By now you probably have the idea of how the UP SHIFT ON/OFF
statement works. This next example will reinforce you knowledge.
The IF statement
-------------------------------------------------------------
The user must have selected option 3 or the field processing
statements for this field will not be processed.
The REQUIRED statement
-------------------------------------------------------------
Notice because REQUIRED is coded AFTER the IF statement that
this field is only REQUIRED if option 3 has been selected.
Notice also that the default REQUIRED message has been
displayed on the message line and that the cursor is on the
first field of the option 3 section of the screen.
The UP SHIFT statement
-------------------------------------------------------------
The UP SHIFT statement coded here will cause the character
comparison to be done with no regard to character case.
Page T-2.12
The IN statement
-------------------------------------------------------------
This IN statement will test that the user has keyed either ON
or OFF in this field. Any other value will be rejected.
Next look at the processing specifications defined on the next
field "UpString".
The IF statement 1
-------------------------------------------------------------
This IF statement will cause the field processing statements
for this field to be skipped if OP is not option 3.
The IF statement 2
-------------------------------------------------------------
Because no UP SHIFT ON statement has been coded here, the
processing statements will have to test for all the different
character case combinations that can occur for "off".
You might wonder why this approach was taken. The reason is
that an UP SHIFT OFF statement can not be used inside an IF
statement. In this particular case we need to test the value
keyed into this field in the case that it is keyed in as.
Notice the upper and lower case mix in the IN statements
literal that it is using to test the fields value against. So
it was necessary to allow for the user to type any
combination of upper or lower case characters.
The IN statement 1
-------------------------------------------------------------
The first IN statement inside the action part of the IF
statement tests if the values ARE NOT EQUAL (\ means not
equal) to the literal 'AbCdEfG'. If it is not the message
'The strings do not match' is displayed on the screen. For
Turbo ScrEdit to get beyond this IN statement, the value
keyed into the field would have to be type with upper and
lower case characters exactly as the test value.
The IN statement 2
-------------------------------------------------------------
The second IN statement test if the fields value IS EQUAL (=)
to the literal. If the values test equal then the message
"The strings ar considered the same." is displayed.
The UP SHIFT ON
-------------------------------------------------------------
If Turbo ScrEdit makes it past the above IF statement then
the mode selected must be ON. So the value keyed is to be
tested with UP SHIFT mode set to ON.
Page T-2.13
The IN statement 3
-------------------------------------------------------------
The first of the next two IN statements test to see if the
string keyed into the field DOES NOT match the literal.
Remember case is not considered, only alphabetical characters
are compared. If the fields do not match the message "The
strings are not the same." is displayed.
The IN statement 4
-------------------------------------------------------------
By the time control gets to the last IN statement for this
field, the value keyed into the field will have to be a match
to the test string and the message "The Strings are
considered the same." will be displayed.
Go ahead and try playing with this example.
When you are ready to continue PRESS F9 to re-init the screen.
The next option on this screen will demonstrate date field
editing. You can use the DATE option to build masks that turbo
scredit will use to validate that a date is valid.
Be sure to look up DATE in the on-line help system before you
continue.
The IF statement 1
-------------------------------------------------------------
Again, the field processing statements in this section are
only to be processed if the user has selected option '4'.
The IF statements 2 thru 6
-------------------------------------------------------------
These if statement test the value of T for 1 thru 5. Each of
the DATE statements will edit the value of Date_Field
according to the DATE MASK defined in the IF statement action
section.
The value keyed by the user must match the selected date mask
exactly, including punctuation.
Usually you will use only one date format on a field and you
will use an EDIT MASK to place the special punctuation into
the field. EDIT MASK's are explained next.
Go ahead and try this option out. Try all five date options.
When you are ready to continue PRESS F9.
The final option demonstrates using EDIT MASKS.
Page T-2.14
Look up EDIT in the on-line help system and read the text.
Locate the field "EditMask" on the screen listing. It will be the
last field listed.
Type: 5 and PRESS ENTER
Notice that the cursor has moved to the field in the option 5
section of the screen, and that the field is no longer empty, but
has changed and now has a number of characters spread out through
it.
Before we look at how the EDIT MASK works lets look at the field
processing statements that have been defined for this field.
The EDIT statement
-------------------------------------------------------------
The Edit statement establishes a edit mask that is to be used
for a field. Any time Turbo ScrEdit gets ready to accept data
entry into a field, it checks to see if the field has a Edit
Mask
The IF statement
-------------------------------------------------------------
This if statement will cause Turbo ScrEdit to skip this field
if the Option is not equal to 5.
The REQUIRED statement
-------------------------------------------------------------
This statement has been defined here to cause the cursor to
come to this field when option 5 is selected. Notice that the
field is not REQUIRED if the option field is not 5.
Now lets turn our attention to the example on the screen. Be sure
before we precede that you read the on-line help section on the
EDIT statement. Or re-read it if you do not understand what each
of the edit characters (#,3,$,4,@,2) mean.
Next notice that a copy of the edit mask "$$$/###-333(@@@:@@@)$"
has been type in the border directly below the screen field. Use
this as a guide when typing characters into the field.
PRESS TAB 5 times.
Notice each time you press the TAB key the cursor moves to the
next section of the edit mask instead of to the next field on the
screen.
Edit masks actually cause a field to be broken into smaller
fields inside of the original field.
PRESS SHIFT and TAB 5 times.
Page T-2.15
Now the cursor should be back on the first section of the field.
PRESS the "*" key four or five times.
An error message was displayed on the bottom line of the screen
when you tried to type the 4th * into the field. The message
states that only the characters '0' thru '9' can be keyed in to
the field at that point. Notice that In the mask below the field
we see that we tried to type a none numeric character where a
numeric mask character (#,3) is in the edit mask.
PRESS the "3" key 7 or 8 times.
Again when we tried to type a numeric character into the the
field where a alphabetic (@,2) mask character is defined.
PRESS "A" 3 times
PRESS "B" 4 times
PRESS SHIFT TAB
Now the cursor is back on the first character of the field in the
option 5 section of the screen.
PRESS the INSERT key until the INSERT label is highlighted
in the toggle key status line.
PRESS 'X'
Notice that the "X" character was inserted into the field, but
only in the section defined by that particular type of edit mask
character.
PRESS DEL 2 times
Characters are deleted only in the first section of the edit
mask.
PRESS TAB
PRESS DEL
Notice in this section of the field and the next that the edit
mask has been defined using both numeric field edit characters
'###-333'. Because we have defined these two area with different
characters they will still be handled as two distinct fields.
When we deleted the character if effected only the first section.
PRESS TAB 2 times
Notice now how this section of the edit mask is defined as
"(@@@:@@@)". Again we have two fields defined, but they are of
the same edit type and we have filled them with the values
'AAA:BBB'.
PRESS DEL
Page T-2.16
Notice this time that when the "A" is deleted that a "B"
character has moved into this field and that the blank has been
appended to the end of the next field. This demonstrates how
Turbo ScrEdit considers consecutive sections of a edit mask
defined with the same edit character as though the are the same
field.
Make sure that INSERT MODE is still on.
PRESS "Z" 3 times
As you typed characters into the left side of this section the
characters moved ahead of the cursor into the right side of the
field and was truncated of the right most character.
That concludes PART II of the tutor. As you can see, Turbo
ScrEdit's field processing language is simple to use and has many
powerful features that can save you hours programming time.